package com.qf.zyh.web.controller;

import com.qf.zyh.common.Const;
import com.qf.zyh.entity.BookInfo;
import com.qf.zyh.services.InfoSer;
import com.qf.zyh.web.controller.BaseServlet;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/info")
public class InfoSerclet extends BaseServlet {
    public String getadd(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
        InfoSer anIf = (InfoSer) ac.getBean("if");
        List<BookInfo> getall = anIf.getall();
        req.setAttribute("list",getall);
        getall.forEach(System.out::println);
        return Const.SysConst.FORWARD+"index.jsp";
    }
}
